package week10;

public class Magazine implements Comparable<Magazine>{
    private String title;

    public Magazine (String newTitle) {
        title = newTitle;
    }

    @Override
    public String toString() {
        return title;
    }

    @Override
    public int compareTo(Magazine mag) {
        int i = 0;
        int a = 0;
        while (title.charAt(i) == mag.toString().charAt(i)) {
            i++;
        }
        if ((int) (title.charAt(i)) < (int) (mag.toString().charAt(i)))
            a = -1;
        else
            a = 1;
        return a;
    }
}
